package com.yellowpage.omc.keyword.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.omc.keyword.data.KeywordLog;
import com.yellowpage.omc.keyword.dao.KeywordLogDao;

public class KeywordLogServiceImpl extends BaseServiceImpl implements KeywordLogService {
	  private KeywordLogDao keywordLogDao;
	
	  public void setKeywordLogDao(KeywordLogDao keywordLogDao) {
		  this.keywordLogDao = keywordLogDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public KeywordLog getKeywordLog(Long id){
	      return keywordLogDao.get(id);
	  }
	  
    public List<KeywordLog> getAllKeywordLog(){
        return keywordLogDao.getAll();
    }
    
    public List<Map> queryKeywordLogByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.KEYWORD_LOG_ID , a.KEYWORD_ID , a.CREATE_USER , a.CREATE_TIME , a.TYPE , a.CONTENT    FROM OMC_KEYWORD_LOG a WHERE 1=1 ")
				    			.addCondition(" and KEYWORD_LOG_ID = :keywordLogId ")
							    			.addCondition(" and KEYWORD_ID = :keywordId ")
							    			.addCondition(" and CREATE_USER = :createUser ")
							    		    .addCondition(" and date_format(CREATE_TIME,'%Y-%m-%d') =  :createTime  ")
		    				    			.addCondition(" and TYPE = :type ")
							    			.addCondition(" and CONTENT = :content ")
							    ; 		    
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveKeywordLog(KeywordLog keywordLog){
        keywordLogDao.save(keywordLog);
    }
    
	  public void updateKeywordLog(KeywordLog keywordLog){
	      keywordLogDao.update(keywordLog);
	  }
	  
	  public void delete(List deleteList){
	      keywordLogDao.remove(deleteList);
	  }
	  
	  
	 
	
}	